package SM::Server::Client;

use warnings;
use strict;

use Data::Dumper::Simple;

# This is the object that is created every time a client connects
# In the future it will hold their logon name, etc.

sub new {
	my ( $class, $arg_ref ) = @_;
	
	# Default location
	my %location = ( 'x' => 5, 'y' => 6, );
	
	# TODO: Actually implement areas
	my $area = "Default";
	
	# Default Attributes
	my %attributes = ( str => 0, agi => 0, int =>, 0, stam => 0 );    

	my $self = bless {
		'session_id' => $arg_ref->{session_id},
		'remote_ip'  => $arg_ref->{remote_ip},
		'username'   => $arg_ref->{username},
		'location'   => \%location,
		'area'       => $area,
		'attributes' => \%attributes,
	}, $class;

	#print Dumper($self);
	return $self;
}

# Authorization code
sub authorize_client {
	my ( $self, $packet ) = @_;

}

# This is where the validation code can go
sub update_location {
	my ( $self, $newx, $newy ) = @_;

	$self->{location}{x} = $newx;
	$self->{location}{y} = $newy;

	return 0;
}

sub get_username {
	my ($self) = @_;

	return $self->{username};
}

sub get_session_id {
	my ($self) = @_;

	return $self->{session_id};
}

sub get_x {
	my ($self) = @_;

	return $self->{location}{x};
}

sub get_y {
	my ($self) = @_;

	return $self->{location}{y};
}

sub get_area {
	my ($self) = @_;

	return $self->{area};
}

1;
